<template>
  <div class="mod-sp__spmatchitemteam">
    <el-form :inline="true" :model="dataForm" @keyup.enter="getDataList()">
      <el-form-item>
        <el-button @click="uploadCertificate()" type="primary">上传选手获奖证书</el-button>
      </el-form-item>

      <el-form-item>
        <el-button @click="uploadCertificateTeacher()" type="primary">上传老师获奖证书</el-button>
      </el-form-item>
    </el-form>
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <!-- 弹窗, 发送短信 -->
    <detail v-if="detailVisible" ref="send" @refreshDataList="getDataList"></detail>
  </div>
  <upload v-if="uploadVisible3" ref="upload3" uploadurl="/sp/spmatchitemteam/importCertificate" downloadurl="/sp/spmatchitemteam/exportCertificateError" @refreshDataList="getDataList"></upload>
  <upload v-if="uploadVisible4" ref="upload4" uploadurl="/sp/spmatchitemteam/importCertificateTeacher" downloadurl="/sp/spmatchitemteam/exportCertificateTeacherError" @refreshDataList="getDataList"></upload>
</template>

<script lang="ts">
import useView from "@/hooks/useView";
import { defineComponent, reactive, toRefs } from "vue";
import AddOrUpdate from "./spmatchitemteam-add-or-update.vue";
import Detail from "./spmatchitemteam-detail.vue";
import baseService from "@/service/baseService";
import Upload from "./score-upload.vue";
import { IObject } from "@/types/interface";
export default defineComponent({
  components: {
    AddOrUpdate,
    Detail,
    Upload
  },
  setup() {
    const state = reactive({
      uploadVisible: false,
      uploadVisible2: false,
      uploadVisible3: false,
      uploadVisible4: false,
      getDataListURL: "/sp/spmatchitemteam/signRecord",
      createdIsNeed: false,
      activatedIsNeed: false,
      getDataListIsPage: true,
      exportURL: "/sp/spmatchitemteam/export",
      deleteURL: "/sp/spmatchitemteam",
      deleteIsBatch: true,
      dataForm: {
        matchName: "",
        item: "",
        matchItemId: "",
        teamId: "",
        teamName: "",
        isRise: "",
        status: "0",
        matchId: ""
      },
      activeName: "first",
      detailVisible: false,
      detailId: ""
    });
    return { ...useView(state), ...toRefs(state) };
  },
  watch: {},
  mounted() {
    //获取上个页面传来的参数
    this.dataForm.matchItemId = this.$route.query.id + "";
    this.dataForm.matchId = this.$route.query.matchId + "";
    this.query();
  },
  methods: {
    uploadCertificate() {
      this.uploadVisible3 = true;
      this.$nextTick(() => {
        this.$refs.upload3.init();
      });
    },
    uploadCertificateTeacher() {
      this.uploadVisible4 = true;
      this.$nextTick(() => {
        this.$refs.upload4.init();
      });
    }
  }
});
</script>
